'use strict';

import HTTPUtil from './HTTPUtil'
import Global from './GlobalConst';
import Toast from '../Utils/toast';
export default class RuralLibraryAPIService {
    /**
     * 城市列表
     */
    static citiesList() {
        var url = Global.HOST + '/City/citiesList';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            HTTPUtil.post(url, null).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 通过经纬度返回当前城市
     */
    static get_town(longitude, latitude) {
        var url = Global.HOST + '/City/get_town';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("longitude", longitude);
            formData.append("latitude", latitude);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村馆头部图片
     */
    static ruraLibraryImagesList() {
        var url = Global.HOST + '/City/ruraLibraryImagesList';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            HTTPUtil.post(url, null).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村馆列表
     */
    static ruralLibraryList(longitude, latitude, town, page) {
        var url = Global.HOST + '/City/libraryList';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("longitude", longitude);
            formData.append("latitude", latitude);
            if(town=='全部'){
                formData.append("town", '');
            }else{
                formData.append("town", town);
            }
            formData.append("page", page);
            console.log('formData',formData)
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据！');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村馆详情
     */
    static libraryDetails(token, registered_id, id) {
        var url = Global.HOST + '/City/libraryDetails';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("id", id);
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(id);
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村馆添加收藏
     */
    static collection(token, registered_id, rid) {
        var url = Global.HOST + '/City/collection';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == 202) {
                    Toast.show('收藏成功！');
                    resolve(json.result);
                } else if (json.code == 201) {
                    Toast.show('取消收藏成功！');
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村馆添加评论
     */
    static comment(token, registered_id, rid, content) {
        var url = Global.HOST + '/City/comment';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            formData.append("content", content);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    }
                    if (json.code == 203) {
                        Toast.show('您已评论！');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村馆添加评论图片
     */
    static collectionImg(token, registered_id, cid, images) {
        var url = Global.HOST + '/City/collectionImg';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("cid", cid);
            let file = {uri: 'file://' + images, type: 'multipart/form-data', name: 'images.jpg'};
            formData.append("images", file);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村馆所有评论列表
     */
    static allComments(rid, type,page) {
        var url = Global.HOST + '/City/allComments';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("rid", rid);
            formData.append("type", type);
            formData.append("page", page);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 游玩详情
     */
    static playDetails(token, registered_id, id) {
        var url = Global.HOST + '/City/playDetails';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 特产详情
     */
    static specialtyDetails(token, registered_id, id) {
        var url = Global.HOST + '/City/specialtyDetails';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 住宿详情
     */
    static hotelDetails(token, registered_id, id) {
        var url = Global.HOST + '/City/hotelDetails';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }


    /**
     * 农家有售详情
     */
    static storeDetails(token, registered_id, id) {
        var url = Global.HOST + '/City/storeDetails';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 发起吃什么评论
     */
    static people_comment(token, registered_id, rid, content) {
        var url = Global.HOST + '/City/people_comment';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            formData.append("content", content);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    }
                    if (json.code == 203) {
                        Toast.show('您已评论！');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 添加吃什么评论的图片
     */
    static people_collectionImg(token, registered_id, cid, images) {
        var url = Global.HOST + '/City/people_collectionImg';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("cid", cid);
            let file = {uri: 'file://' + images, type: 'multipart/form-data', name: 'images.jpg'};
            formData.append("images", file);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 发起玩什么评论
     */
    static amuse_comment(token, registered_id, rid, content) {
        var url = Global.HOST + '/City/amuse_comment';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            formData.append("content", content);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    }
                    if (json.code == 203) {
                        Toast.show('您已评论！');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 添加玩什么评论的图片
     */
    static amuse_collectionImg(token, registered_id, cid, images) {
        var url = Global.HOST + '/City/amuse_collectionImg';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("cid", cid);
            let file = {uri: 'file://' + images, type: 'multipart/form-data', name: 'images.jpg'};
            formData.append("images", file);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 添加玩什么收藏
     */
    static amuse_collection(token, registered_id, rid) {
        var url = Global.HOST + '/City/amuse_collection';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == 202) {
                    Toast.show('收藏成功！');
                    resolve(json.result);
                } else if (json.code == 201) {
                    Toast.show('取消收藏成功！');
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 添加吃什么收藏
     */
    static people_collection(token, registered_id, rid) {
        var url = Global.HOST + '/City/people_collection';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == 202) {
                    Toast.show('收藏成功！');
                    resolve(json.result);
                } else if (json.code == 201) {
                    Toast.show('取消收藏成功！');
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 添加住什么收藏
     */
    static hotel_collection(token, registered_id, rid) {
        var url = Global.HOST + '/City/hotel_collection';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == 202) {
                    Toast.show('收藏成功！');
                    resolve(json.result);
                } else if (json.code == 201) {
                    Toast.show('取消收藏成功！');
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }


    /**
     * 发起住什么评论
     */
    static hotel_comment(token, registered_id, rid, content) {
        var url = Global.HOST + '/City/hotel_comment';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            formData.append("content", content);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    }
                    if (json.code == 203) {
                        Toast.show('您已评论！');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 添加住什么评论的图片
     */
    static hotel_collectionImg(token, registered_id, cid, images) {
        var url = Global.HOST + '/City/hotel_collectionImg';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("cid", cid);
            let file = {uri: 'file://' + images, type: 'multipart/form-data', name: 'images.jpg'};
            formData.append("images", file);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 发起店铺评论
     */
    static people_shop_comment(token, registered_id, rid, content) {
        var url = Global.HOST + '/City/people_shop_comment';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("rid", rid);
            formData.append("content", content);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    }
                    if (json.code == 203) {
                        Toast.show('您已评论！');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 添加店铺评论的图片
     */
    static people_shopImg(token, registered_id, cid, images) {
        var url = Global.HOST + '/City/people_shopImg';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("token", token);
            formData.append("registered_id", registered_id);
            formData.append("cid", cid);
            let file = {uri: 'file://' + images, type: 'multipart/form-data', name: 'images.jpg'};
            formData.append("images", file);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 获取店铺的所有评论
     */
    static getStoreComment(id,page) {
        var url = Global.HOST + '/City/getStoreComment';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("id", id);
            formData.append("page", page);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 获取店铺的所有商品
     */
    static getStoreFoot(id) {
        var url = Global.HOST + '/City/getStoreFoot';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 获取头条号列表
     */
    static get_headline(rid) {
        var url = Global.HOST + '/City/get_headline';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("rid", rid);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 农人故事详情
     */
    static farmerStoryDetails(id) {
        var url = Global.HOST + '/City/farmerStoryDetails';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 村长说详情
     */
    static villageChiefDetails(id) {
        var url = Global.HOST + '/City/villageChiefDetails';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('参数不能为空');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村更多数据
     */
    static beerAndSkittlesList(id) {
        var url = Global.HOST + '/City/beerAndSkittlesList';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json.result);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

    /**
     * 乡村更多活动
     */
    static getActivityList(id) {
        var url = Global.HOST + '/Find/getActivityList';
        return new Promise(function (resolve, reject) {
            let formData = new FormData();
            formData.append("id", id);
            HTTPUtil.post(url, formData).then((json) => {
                console.log(url, json);
                if (json.code == true) {
                    resolve(json);
                } else {
                    if (json.code == 100) {
                        Toast.show('暂无数据');
                    } else {
                        Toast.show('网络错误');
                    }
                    reject(new Error(json.result));
                }
            }).catch((err)=> {
                Toast.show(Global.SERVERERR);
                reject(new Error(Global.SERVERERR));
            });
        });
    }

}